import { EntitySchema } from '@mikro-orm/core';

export class LeUserCoupon {
  id!: string;
  couponId!: string;
  orderSn?: string;
  origin!: boolean;
  useData?: string;
  AppID!: string;
  merchantId!: string;
  createdTime?: number = 0;
  updatedTime?: number = 0;
  deletedTime?: number = 0;
  isRecycle?: boolean = false;
  isDeleted?: number = 0;
  UID!: string;
  goodsId?: string;
  status?: boolean = false;
  beginTime?: string;
  endTime?: string;
  originOrderSn?: string;
  useTime?: string;
  isRemind: boolean = false;
}

export const LeUserCouponSchema = new EntitySchema({
  class: LeUserCoupon,
  indexes: [
    { name: '优惠券来源', properties: ['goodsId', 'originOrderSn'] },
  ],
  uniques: [
  ],
  properties: {
    id: { primary: true, type: 'string', columnType: 'bigint' },
    couponId: { type: 'string', columnType: 'bigint', index: '优惠券ID' },
    orderSn: { type: 'string', length: 50, nullable: true },
    origin: { type: 'boolean' },
    useData: { type: 'string', columnType: 'text', nullable: true },
    AppID: { type: 'string', fieldName: 'AppID', length: 50, index: '应用ID' },
    merchantId: { type: 'string', columnType: 'bigint' },
    createdTime: { type: 'number', nullable: true, default: 0 },
    updatedTime: { type: 'number', nullable: true, default: 0 },
    deletedTime: { type: 'number', nullable: true, default: 0 },
    isRecycle: { type: 'boolean', nullable: true, default: false },
    isDeleted: { type: 'number', columnType: 'tinyint', nullable: true, default: 0 },
    UID: { type: 'string', fieldName: 'UID', columnType: 'bigint', index: '用户ID' },
    goodsId: { type: 'string', columnType: 'bigint', nullable: true },
    status: { type: 'boolean', nullable: true, default: false },
    beginTime: { type: 'string', columnType: 'bigint', nullable: true },
    endTime: { type: 'string', columnType: 'bigint', nullable: true },
    originOrderSn: { type: 'string', length: 50, nullable: true },
    useTime: { type: 'string', columnType: 'bigint', nullable: true },
    isRemind: { type: 'boolean', default: false },
  },
});
